// Decompiled by GOOSIN CO,LTD Copyright 2010 Pavel Kouznetsov.
// home page: http://www.Goosin.net
// Decompiler options: packimports(3) fieldsfirst ansi space 
// Source File Name:   change_ok.java

package hr.engage.resume;

import com.jspsmart.upload.*;
import include.nseer_cookie.getFileLength;
import include.nseer_db.nseer_db_backup1;
import java.io.IOException;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.*;
import javax.servlet.jsp.JspFactory;

public class change_ok extends HttpServlet
{

	ServletContext application;
	HttpSession session;

	public change_ok()
	{
	}

	public synchronized void service(HttpServletRequest request, HttpServletResponse response)
		throws IOException, ServletException
	{
		HttpSession dbSession = request.getSession();
		JspFactory _jspxFactory = JspFactory.getDefaultFactory();
		javax.servlet.jsp.PageContext pageContext = _jspxFactory.getPageContext(this, request, response, "", true, 8192, true);
		ServletContext dbApplication = dbSession.getServletContext();
		try
		{
			HttpSession session = request.getSession();
			java.io.PrintWriter out = response.getWriter();
			nseer_db_backup1 hr_db = new nseer_db_backup1(dbApplication);
			if (hr_db.conn((String)dbSession.getAttribute("unit_db_name")))
			{
				SmartUpload mySmartUpload = new SmartUpload();
				mySmartUpload.setCharset("UTF-8");
				getFileLength getFileLength = new getFileLength();
				String human_ID = request.getParameter("human_ID");
				mySmartUpload.initialize(pageContext);
				mySmartUpload.upload();
				SmartFile myFile = mySmartUpload.getFiles().getFile(0);
				ServletContext context = session.getServletContext();
				String path = context.getRealPath("/");
				String file = myFile.getFileName();
				int a = file.indexOf(".jpg");
				int b = file.indexOf(".gif");
				int c = myFile.getSize();
				double d = include.nseer_cookie.getFileLength.getFileLength((String)dbSession.getAttribute("unit_db_name"));
				if ((double)c < d)
				{
					myFile.saveAs((new StringBuilder(String.valueOf(path))).append("hr/human_pictures/").append(myFile.getFileName()).toString());
					String sql = (new StringBuilder("update hr_file set picture='")).append(file).append("' where human_ID='").append(human_ID).append("'").toString();
					hr_db.executeUpdate(sql);
					response.sendRedirect("hr/engage/resume/change_ok_a.jsp");
				} else
				{
					response.sendRedirect((new StringBuilder("hr/engage/resume/change_ok_a.jsp?human_ID=")).append(human_ID).toString());
				}
				hr_db.commit();
				hr_db.close();
			} else
			{
				response.sendRedirect("error_conn.htm");
			}
		}
		catch (Exception exception) { }
	}
}
